package com.grwx.omc.admin.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.grwx.omc.admin.dao.SysDeviceMapper;
import com.grwx.omc.admin.entity.SysDevice;
import com.grwx.omc.admin.service.ISysDeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;

@Service
public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice> implements ISysDeviceService {
    @Resource
    private SysDeviceMapper sysDeviceMapper;

    @Override
    public IPage<SysDevice> page(Page<SysDevice> page, SysDevice sysDevice) {
        return sysDeviceMapper.pageList(page,sysDevice);
    }

    @Override
    public void addOrUpdate(SysDevice sysDevice) {
        if(null==sysDevice.getId()){
            sysDevice.preInsert();
            save(sysDevice);
        }else {
            sysDevice.preUpdate();
            updateById(sysDevice);
        }
    }

    @Override
    public void del(Long[] ids) {
        removeByIds(Arrays.asList(ids));
    }
}
